package com.course.service.impl;
import com.course.entity.ResultBody;
import com.course.mapper.UserManMapper;
import com.course.service.UserManService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;
@Service
public class UserManServiceimpl implements UserManService {
    @Autowired
    private UserManMapper userManMapper;
    @Override
    public ResultBody delectUser(Map<String,Object> map)
    {
        if(userManMapper.delectUser(map)>0)
        {
            return new ResultBody(200,"删除用户成功",true);
        }
        else
            return new ResultBody(400,"删除用户失败",false);
    }
    @Override
    public ResultBody updateUser(Map<String,Object> map)
    {
        if(userManMapper.updateUser(map)>0)
        {
            return new ResultBody(200,"更新用户成功",true);
        }
        else
            return new ResultBody(400,"更新用户失败",false);
    }
    @Override
    public ResultBody addUser(Map<String,Object> map)
    {
        if(userManMapper.addUser(map)>0)
        {
            return new ResultBody(200,"添加用户成功",true);
        }
        else
            return new ResultBody(400,"添加用户失败",false);
    }
    @Override
    public ResultBody displayUser()
    {
        if(!userManMapper.displayUser().isEmpty()) {
            return new ResultBody(200, "显示用户成功", userManMapper.displayUser(), userManMapper.displayUser().size());
        }
        else if(userManMapper.displayUser().isEmpty())
        {
            return new ResultBody(200,"在那屋相关内容", userManMapper.displayUser());
        }
        return new ResultBody(500,"显示失败",false);
    }
    @Override
    public ResultBody addteacher(Map<String,Object> map)
    {
        if(userManMapper.addteacher(map)>0)
        {
            return new ResultBody(200,"添加用户成功",true);
        }
        else
            return new ResultBody(400,"添加用户失败",false);
    }

    @Override
    public ResultBody displayteacher()
    {
        if(!userManMapper.displayteacher().isEmpty()) {
            return new ResultBody(200, "显示用户成功", userManMapper.displayteacher(), userManMapper.displayteacher().size());
        }
        else if(userManMapper.displayteacher().isEmpty())
        {
            return new ResultBody(200,"在那屋相关内容", userManMapper.displayteacher());
        }
        return new ResultBody(500,"显示失败",false);
    }

}
